# Makefile for TPIE test applications.
# Use gmake on this Makefile.  It relies on the default rules, and 
# Use gmake -p to see the default rules.
# $Id: Makefile.in,v 1.31 2002/02/02 18:19:17 tavi Exp $

CXX = @CXX@
CC = @CC@
MAKEDEPEND = @CXX@ -M

TPIEINC = ../include
TPIELIBDIR = ../lib
TPIELIB = $(TPIELIBDIR)/libtpie.a

ifdef DEBUG_APPS
LOG_APPS = 1
ASSERT_DEBUG_APPS = 1
endif

CXXFLAGS = 

# CPPFLAGS is used by the default rules. Using "override" and "+="
# allows the user to prepend things to CPPFLAGS on the command line.
override CPPFLAGS +=  -I$(TPIEINC)
# These options are set by the configure script.
override CPPFLAGS += @DEFS@

ifeq ($(MINUSG),1)
override CPPFLAGS += -g
else
override CPPFLAGS += -O3
endif

ifeq ($(MINUSPG),1)
override CPPFLAGS += -pg
endif

LDLIBS =  -L$(TPIELIBDIR) -ltpie -lm #-liberty

CCFLAGS = $(CXXFLAGS)

# The various test applications.

APPS := test_ami_pmerge \
	test_ami_sort \
	test_ami_merge \
	test_ami_gp \
	test_matrix \
	test_bit_matrix \
	test_ami_arith \
	test_ami_matrix	\
	test_ami_matrix_pad \
	test_ami_stack \
	test_ami_bp \
	lr \
	ch2 \
	test_ami_sm \
	nas_ep \
	nas_ep2 \
	nas_cg \
	nas_is \
	test_ami_sort24	\
	nas_ep_mm \
	smooth \
	sample_pgm \
	test_ami_btree

# Sources to the test applications.
APPSRC = $(patsubst %,%.C,$(APPS))

# Other C++ sources for common support routines.
COMMONCXXSRC = parse_args.C \
	app_config.C

OTHERCXXSRC = scan_random.C \
	scan_count.C \
	scan_list.C \
	list_edge.C \
	scan_random_point.C \
	scan_uniform_sm.C

CXXSRC = $(APPSRC) $(COMMONCXXSRC) $(OTHERCXXSRC)

# Common objects that go into most apps.
COMMONOBJ = $(COMMONCXXSRC:.C=.o)

# C sources.
CSRC = int_cmp.c

# Translation rules:

%:%.o
	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@


# Specific dependencies, explicit and automatic.

all: $(APPS)

depend: cleandepend 
	$(MAKEDEPEND) $(CPPFLAGS) $(CSRC) $(CXXSRC) >> Makefile.depend

clean: cleandepend
	-rm -f $(CSRC:.c=.o) $(CXXSRC:.C=.o) $(APPS)

distclean: clean


# What objects each of the apps acually needs.

test_ami_pmerge: test_ami_pmerge.o scan_random.o int_cmp.o $(COMMONOBJ)
test_ami_sort: test_ami_sort.o scan_random.o $(COMMONOBJ)
test_ami_merge: test_ami_merge.o scan_count.o $(COMMONOBJ)
test_ami_gp: test_ami_gp.o scan_count.o $(COMMONOBJ)
test_ami_bp: test_ami_bp.o scan_count.o $(COMMONOBJ)
test_util_matrix: test_util_matrix.o
test_bit_matrix: test_bit_matrix.o
test_ami_arith: test_ami_arith.o scan_count.o $(COMMONOBJ)
test_ami_matrix_pad: test_ami_matrix_pad.o scan_count.o	$(COMMONOBJ)
test_ami_matrix: test_ami_matrix.o scan_count.o $(COMMONOBJ)
test_ami_stack: test_ami_stack.o $(COMMONOBJ)
lr: lr.o list_edge.o scan_list.o $(COMMONOBJ)
ch2: ch2.o scan_random_point.o $(COMMONOBJ)
test_ami_sm: test_ami_sm.o scan_uniform_sm.o $(COMMONOBJ)
nas_ep: nas_ep.o $(COMMONOBJ)
nas_ep2: nas_ep2.o $(COMMONOBJ)
nas_cg: nas_cg.o $(COMMONOBJ)
nas_is: nas_is.o $(COMMONOBJ)
nas_ep_mm: nas_ep_mm.o 
test_ami_sort24: test_ami_sort24.o $(COMMONOBJ)
smooth: smooth.o scan_build_smoother.o  $(COMMONOBJ)
sample_pgm: sample_pgm.o $(COMMONOBJ)
test_ami_btree: test_ami_btree.o

include Makefile.depend

Makefile.depend: #$(CSRC) $(CXXSRC)
	rm -f Makefile.depend; \
	$(MAKEDEPEND) $(CPPFLAGS) $(CSRC) $(CXXSRC) >> Makefile.depend

cleandepend:
	-rm -f Makefile.depend

.PHONY : clean all depend cleandepend distclean


